package com.serkol.driving.learning.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.serkol.bean.MyPage;
import com.serkol.driving.learning.entity.LearningType;
import com.serkol.driving.learning.mapper.LearningTypeMapper;
import com.serkol.driving.learning.service.LearningTypeService;
import com.serkol.driving.learning.handler.MyLambdaQueryWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
* @author pingan
* @description 针对表【learning_type】的数据库操作Service实现
* @createDate 2022-06-07 00:16:41
*/
@Service
public class LearningTypeServiceImpl extends ServiceImpl<LearningTypeMapper, LearningType>
    implements LearningTypeService{

    @Override
    public MyPage findByList(int pageSize, int current) {
        QueryWrapper<LearningType> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("ID");
        Page<LearningType> page = new Page<>(current, pageSize);
        IPage<LearningType> loginLogPage = this.baseMapper.selectPage(page, queryWrapper);
        return MyPage.parsePage(loginLogPage);
    }

    @Override
    public List<Map<String, Object>> findByListMini() {
        MyLambdaQueryWrapper<LearningType> queryWrapper = new MyLambdaQueryWrapper<>();
        queryWrapper.select(LearningType::getId, LearningType::getIcon)
                .langName(LearningType::getName, LearningType::getUgName).as("name");
        return this.listMaps(queryWrapper);
    }
}




